@import "../../mixins/_index.less";

.gen-grid-columns(@index, @class) when (@index > 0) {

  .@{prefix}-col@{class}-@{index} {
    display: block;
    flex: 0 0 percentage((@index / @grid-columns));
    max-width: percentage((@index / @grid-columns));
  }

  .@{prefix}-col@{class}-push-@{index} {
    left: percentage((@index / @grid-columns));
  }

  .@{prefix}-col@{class}-pull-@{index} {
    right: percentage((@index / @grid-columns));
  }

  .@{prefix}-col@{class}-offset-@{index} {
    margin-left: percentage((@index / @grid-columns));
  }

  .@{prefix}-col@{class}-order-@{index} {
    order: @index;
  }
  .gen-grid-columns((@index - 1), @class);
}

.gen-grid-columns(@index, @class) when (@index = 0) {

  .@{prefix}-col@{class}-@{index} {
    display: none;
  }

  .@{prefix}-col-push-@{index} {
    left: auto;
  }

  .@{prefix}-col-pull-@{index} {
    right: auto;
  }

  .@{prefix}-col@{class}-push-@{index} {
    left: auto;
  }

  .@{prefix}-col@{class}-pull-@{index} {
    right: auto;
  }

  .@{prefix}-col@{class}-offset-@{index} {
    margin-left: 0;
  }

  .@{prefix}-col@{class}-order-@{index} {
    order: 0;
  }
}

.gen-grid(@class: ~'') {
  .gen-grid-columns(@grid-columns, @class);
}
